package com.jzc.rabbit.common;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class MyRabbitMqUtils {
    public static Connection getChannel() throws IOException, TimeoutException {
        //1.创建连接工厂

        ConnectionFactory connectionFactory = new ConnectionFactory();
        //2.设置参数
        // ip 默认localhost
        connectionFactory.setHost("192.168.221.10");
        // amqp端口默认5672
        connectionFactory.setPort(5672);
        // 虚拟机名称 默认/
        connectionFactory.setVirtualHost("/");
        // 用户 默认guest
        connectionFactory.setUsername("guest");
        // 密码 默认guest
        connectionFactory.setPassword("guest");
        //3.创建连接 Connection
        Connection connection =connectionFactory.newConnection();
        //4.创建Channel
        return connection;
    }





}
